#include "Scene/RenderOperation.h"

#include "GfxDriver/GfxDriver.h"

#include <cassert>

namespace Orca {

	//--------------------------------------------------------------------------
	RenderOperation::RenderOperation(
		VertexInput *vertInput, 
		PrimitiveType primType,
		bool indexed,
		uint32 start,
		uint32 cnt) :
	
		mVertexInput(vertInput),
		mPrimType(primType),
		mIndexed(indexed),
		mStart(start),
		mCnt(cnt) {

	}

	//--------------------------------------------------------------------------
	RenderOperation::~RenderOperation() {

	}

	//--------------------------------------------------------------------------
	void RenderOperation::beginRender(GfxDriver *gfxDriver) {

		assert(gfxDriver);

		gfxDriver->beginDrawing(mVertexInput);
	}

	//--------------------------------------------------------------------------
	void RenderOperation::render(GfxDriver *gfxDriver) {

		assert(gfxDriver);

		if(mIndexed)
			gfxDriver->drawIndexed(mPrimType, mStart, mCnt);
		else
			gfxDriver->draw(mPrimType, mStart, mCnt);
	}

	//--------------------------------------------------------------------------
	void RenderOperation::endRender(GfxDriver *gfxDriver) {

		assert(gfxDriver);

		gfxDriver->endDrawing();
	}

	//--------------------------------------------------------------------------
}